package com.ja.openchat.viewmodels;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.ja.openchat.ui.chat.SettingBackgroudActivity;
import com.ja.openchat.ui.chat.group.GroupSendActivity;
import com.zy.openchat.Constants;
import com.zy.openchat.util.SPUtils;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.binding.command.BindingCommand;


public class CommonSetViewModel extends BaseViewModel {
    public ObservableField<Boolean> enterKeyForSendIsChecked = new ObservableField<>(true);
    public CommonSetViewModel(@NonNull Application application) {
        super(application);
        resetUI();
    }

    private void resetUI(){
        enterKeyForSendIsChecked.set(SPUtils.getBoolean(getApplication(), Constants.SPU_FOR_ENTER_KEY_FOR_SEND,true));
    }

    public BindingCommand toggleEnterKey = new BindingCommand(() -> {
        boolean isChecked = !enterKeyForSendIsChecked.get();
        SPUtils.put(getApplication(),Constants.SPU_FOR_ENTER_KEY_FOR_SEND,isChecked);
        enterKeyForSendIsChecked.set(isChecked);
    });

    //点击事件
    public BindingCommand btnOnClickCommand = new BindingCommand(() -> {

    });
    //背景点击事件
    public BindingCommand bgBtnOnClickCommand = new BindingCommand(() -> {
        startActivity(SettingBackgroudActivity.class);
    });

    public BindingCommand groupSendBtnOnClickCommand = new BindingCommand(() -> {
        startActivity(GroupSendActivity.class);
    });
}
